populatePointerFile restage k obj f = go =<< liftIO (isPointerFile f)
where
go (Just k') | k == k' = do
- let f' = fromOsPath f
destmode <- liftIO $ catchMaybeIO $
- fileMode <$> R.getFileStatus f'
- liftIO $ removeWhenExistsWith R.removeLink f'
+ fileMode <$> R.getFileStatus (fromOsPath f)
+ liftIO $ removeWhenExistsWith removeFile f
(ic, populated) <- replaceWorkTreeFile f $ \tmp -> do
ok <- linkOrCopy k obj tmp destmode >>= \case
Just _ -> thawContent tmp >> return True
- Does not check if the pointer file is modified. -}
depopulatePointerFile :: Key -> OsPath -> Annex ()
depopulatePointerFile key file = do
- let file' = fromOsPath file
- st <- liftIO $ catchMaybeIO $ R.getFileStatus file'
+ st <- liftIO $ catchMaybeIO $ R.getFileStatus (fromOsPath file)
let mode = fmap fileMode st
secureErase file
- liftIO $ removeWhenExistsWith R.removeLink file'
+ liftIO $ removeWhenExistsWith removeFile file
ic <- replaceWorkTreeFile file $ \tmp -> do
liftIO $ writePointerFile tmp key mode
#if ! defined(mingw32_HOST_OS)
Nothing -> return is_locked
Just lockhandle -> do
dropLock lockhandle
- void $ tryIO $ removeWhenExistsWith R.removeLink lockfile
+ void $ tryIO $ removeWhenExistsWith removeFile lockfile
return is_unlocked
, return is_missing
)
replacedotgit = whenM (doesFileExist dotgit) $ do
linktarget <- relPathDirToFile w d
- let dotgit' = fromOsPath dotgit
- removeWhenExistsWith R.removeLink dotgit'
- R.createSymbolicLink (fromOsPath linktarget) dotgit'
+ removeWhenExistsWith removeFile dotgit
+ R.createSymbolicLink (fromOsPath linktarget) (fromOsPath dotgit)
-- Unsetting a config fails if it's not set, so ignore failure.
unsetcoreworktree = void $ Git.Config.unset "core.worktree" r
relatedTemplate $ fromOsPath $
literalOsPath "ingest-" <> takeFileName file
hClose h
- removeWhenExistsWith R.removeLink (fromOsPath tmpfile)
+ removeWhenExistsWith removeFile tmpfile
withhardlink' delta tmpfile
`catchIO` const (nohardlink' delta)
makeGitLink :: LinkTarget -> OsPath -> Annex ()
makeGitLink linktarget file = ifM (coreSymlinks <$> Annex.getGitConfig)
( liftIO $ do
- void $ tryIO $ R.removeLink file'
- R.createSymbolicLink linktarget file'
+ void $ tryIO $ removeFile file
+ R.createSymbolicLink linktarget (fromOsPath file)
, liftIO $ F.writeFile' file linktarget
)
- where
- file' = fromOsPath file
{- Creates a link on disk, and additionally stages it in git. -}
addAnnexLink :: LinkTarget -> OsPath -> Annex ()
tmpdir <- fromRepo gitAnnexTmpOtherDir
void $ liftIO $ tryIO $ removeDirectoryRecursive tmpdir
oldtmp <- fromRepo gitAnnexTmpOtherDirOld
- liftIO $ mapM_ (cleanold . fromOsPath)
+ liftIO $ mapM_ cleanold
=<< emptyWhenDoesNotExist (dirContentsRecursive oldtmp)
-- remove when empty
liftIO $ void $ tryIO $ removeDirectory oldtmp
cleanold f = do
now <- liftIO getPOSIXTime
let oldenough = now - (60 * 60 * 24 * 7)
- catchMaybeIO (modificationTime <$> R.getSymbolicLinkStatus f) >>= \case
+ catchMaybeIO (modificationTime <$> R.getSymbolicLinkStatus (fromOsPath f)) >>= \case
Just mtime | realToFrac mtime <= oldenough ->
- void $ tryIO $ removeWhenExistsWith R.removeLink f
+ void $ tryIO $ removeWhenExistsWith removeFile f
_ -> return ()
-}
maybe noop dropLock moldlockhandle
dropLock lockhandle
- void $ tryIO $ R.removeLink lckfile
+ void $ tryIO $ removeFile lckfile
maybe noop (void . tryIO . removeFile) moldlckfile
#endif
<$> liftIO (getDirectoryContents rpmrepo)
forM_ tarrpmarches $ \(tararch, rpmarch) ->
forM_ (filter (isstandalonetarball tararch . fst) l) $ \(tarball, v) -> do
- liftIO $ mapM_ (removeWhenExistsWith (R.removeLink . toRawFilePath))
+ liftIO $ mapM_ (removeWhenExistsWith removeFile)
(filter ((rpmarch ++ ".rpm") `isSuffixOf`) oldrpms)
void $ liftIO $ boolSystem script
[ Param rpmarch
| want /= fromInternalGitPath have = do
showNote "fixing link"
createWorkTreeDirectory (parentDir file)
- liftIO $ R.removeLink (fromOsPath file)
+ liftIO $ removeFile file
addAnnexLink (fromOsPath want) file
| otherwise = noop